package com.bodu.member.service.impl;

import com.bodu.member.entity.vo.MemberUserVo;
import com.bodu.member.mapper.MemberUserMapper;
import com.bodu.member.service.MemberUserService;
import com.bodu.core.entity.ParamReq;
import com.bodu.member.entity.request.MemberUserRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 成员用户表 Service impl
 *
 * @author Administrator
 */
@Service
public class MemberUserServiceImpl implements MemberUserService {

    @Resource
    private MemberUserMapper memberUserMapper;

    @Override
    public MemberUserVo getModel(Long id) {
        return memberUserMapper.getModel(id);
    }

    @Transactional
    @Override
    public Long save(MemberUserRequest memberUserRequest) {
        memberUserMapper.save(memberUserRequest);
        return memberUserRequest.getId();
    }

    @Transactional
    @Override
    public Long update(MemberUserRequest memberUserRequest) {
        memberUserMapper.update(memberUserRequest);
        return memberUserRequest.getId();
    }

    @Override
    public List<MemberUserVo> listPage(ParamReq<MemberUserRequest> params) {
        params.setStartIndex((params.getCurrent() - 1) * params.getSize());
        return memberUserMapper.listPage(params);
    }

    @Override
    public Integer countPage(ParamReq<MemberUserRequest> params) {
        return memberUserMapper.countPage(params);
    }

    @Override
    public Integer updateDelFlagById(Long id, Integer delFlag) {
        return memberUserMapper.updateDelFlagById(id, delFlag);
    }

    @Override
    public MemberUserVo getModelByOpenId(String openid) {
        return memberUserMapper.getModelByOpenId(openid);
    }
}
